package com.qlmjx.sevalopos.https;

import android.content.Context;
import android.util.Log;


import com.alibaba.fastjson.JSON;
import com.qlmjx.sevalopos.Bean.CustomerGoodsBean;
import com.qlmjx.sevalopos.utils.ConstantsUtils;
import com.universal.frame.generalutils.JsonUtil;
import com.universal.frame.generalutils.LogUtils;
import com.universal.frame.generalutils.SharedPreferencesUtil;
import com.universal.frame.generalutils.ToastUtil;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class RequestParams {

    public String TAG = "RequestParams";

    /***
     * 登录ID
     */
    public String userId = "";

    /**
     * 用户token
     */
    public String token;

    private Context context;

    public static int limit = 30;

    public static String merchantCode = "10000";


    public RequestParams(Context context) {
        super();
        if (SharedPreferencesUtil.getBoolean(context, ConstantsUtils.IS_LOGIN, false)) {
            userId = SharedPreferencesUtil.getString(context, ConstantsUtils.USER_ID);
        }
    }

    /**
     * 通用参数请求
     */
    public Map<String, String> getParams() {
        Map<String, String> params = new HashMap<String, String>();
        params.put("userId", userId);
        return params;
    }

    /**
     *
     */
    public Map<String, String> getUserIdParams(String userId) {
        Map<String, String> params = new HashMap<String, String>();
        params.put("userId", userId);
        return params;
    }

    /***
     * 登录
     *
     * @param password 密码
     * @return
     */
    public Map<String, String> getLoginParams(String username, String password) {
        Map<String, String> params = new HashMap<String, String>();
        params.put("userName", username);
        params.put("password", password);
        return params;
    }

    /**
     * 查询会员折扣
     *
     * @param vipNumber vipid
     * @return
     */
    public Map<String, String> getSaleInfoParams(String vipNumber) {
        Map<String, String> params = new HashMap<String, String>();
        params.put("vipNumber", vipNumber);
        return params;
    }

    /***
     * 根据手机查询用户
     *
     * @param phoneNumber 手机号
     * @return
     */
    public Map<String, String> getSearchMemberParams(String phoneNumber) {
        Map<String, String> params = new HashMap<String, String>();
        params.put("phoneNumber", phoneNumber);
        return params;
    }

    /***
     * 根据订单 ID申请折扣价
     *
     * @param  keyId 订单ID
     * @return
     */
    public Map<String, String> getApplyParams(String keyId) {
        Map<String, String> params = new HashMap<String, String>();
        params.put("keyId", keyId);
        return params;
    }
    /***
     * 查询审核状态
     *
     * @param  keyId 订单ID
     * @return
     */
    public Map<String, String> getStateParams(String keyId) {
        Map<String, String> params = new HashMap<String, String>();
        params.put("keyId", keyId);
        return params;
    }
    /***
     * 根据机号获取机型
     *
     * @param  serialNo 机号
     * @return
     */
    public Map<String, String> getModelParams(String serialNo) {
        Map<String, String> params = new HashMap<String, String>();
        params.put("serialNo", serialNo);
        return params;
    }

//    /***
//     * 获取商品信息
//     *
//     * @param sort
//     * @return
//     */
//    public Map<String, String> getShopParams(String sort, int page) {
//        Map<String, String> params = new HashMap<String, String>();
//        params.put("order", "asc");
//        params.put("sort", "part_id");
//        params.put("rows", limit + "");
//        params.put("page", page + "");
//        params.put("filter.part_no", sort);
//        return params;
//    }
    /***
     * 获取商品信息本地
     *
     * @param companyId
     * @return
     */
    public Map<String, String> getShopParams(String companyId, String content) {
        Map<String, String> params = new HashMap<String, String>();
        params.put("companyId",companyId);
        params.put("content", content);
        return params;
    }
    /***
     * 0保存订单
     *
     * @param saleCustId 客户ID
     *        vipNumber VIP号码
     *
     * @return
     */
    public Map<String, String> getZeroOrderParams(String userId,String saleCustId, String vipNumber, String warehouseId
            , String companyId, String deptId, String createDate, String machineId, String modelId, String isDiscount
            ,  List<CustomerGoodsBean> list) {
//        List<String> partId, List<String> partNum, List<String> partSalePrice, List<String> partCat
        Map<String, String> params = new HashMap<String, String>();
        params.put("userId", userId);//登录员ID
        params.put("saleCustId", saleCustId);//客户ID
        if (!"".equals(vipNumber)){
            params.put("vipNumber", vipNumber);//VIP编号
        }
        params.put("warehouseId", warehouseId);//仓库号
        params.put("companyId", companyId);//公司ID
        params.put("deptId", deptId);//所属部门
        params.put("createDate", createDate);//时间
        params.put("machineId", machineId);//机号
        params.put("modelId", modelId);//机型
        params.put("isDiscount", isDiscount);//打折类型
        params.put("isSy", "1");//固定值
        params.put("list",  JSON.toJSONString(list));//VIP编号

//        for (int i = 0; i < partId.size(); i++) {
//            params.put("parts[" + i + "].partId", partId.get(i));
//            params.put("parts[" + i + "].partNum", partNum.get(i));
//            params.put("parts[" + i + "].partSalePrice", partSalePrice.get(i));
//            params.put("parts[" + i + "].partCat", partCat.get(i));
//        }
        Log.i(TAG, "getZeroOrderParams: "+params);
        return params;


    }
    /***
     * 0保存订单
     *
     * @param saleCustId 客户ID
     *        vipNumber VIP号码
     *
     * @return
     */
    public Map<String, String> getwoOneOrderParams(String userId,String saleCustId, String vipNumber, String warehouseId
            ,String companyId, String deptId, String createDate, String machineId, String modelId, String isDiscount, String discountRate
            , List<CustomerGoodsBean> list) {
        Map<String, String> params = new HashMap<String, String>();
        params.put("userId", userId);//登录员ID
        params.put("saleCustId", saleCustId);//客户ID
        if (!"".equals(vipNumber)){
            params.put("vipNumber", vipNumber);//VIP编号
        }
        params.put("warehouseId", warehouseId);//仓库号
        params.put("companyId", companyId);//公司ID
        params.put("deptId", deptId);//所属部门
        params.put("createDate", createDate);//时间
        params.put("machineId", machineId);//机号
        params.put("modelId", modelId);//机型
        params.put("isDiscount", isDiscount);//打折类型
        params.put("discountRate", discountRate);//折扣
        params.put("isSy", "1");//固定值
        params.put("list", JSON.toJSONString(list));
//        for (int i = 0; i < partId.size(); i++) {
//            params.put("parts[" + i + "].partId", partId.get(i));
//            params.put("parts[" + i + "].partNum", partNum.get(i));
//            params.put("parts[" + i + "].partSalePrice", partSalePrice.get(i));
//            params.put("parts[" + i + "].partCat", partCat.get(i));
//        }
        return params;

    }
//
//    /***
//     * 获取未支付订单列表
//     *
//     * @param page
//     * @return
//     */
//    public Map<String, String> getShopListParams(int page) {
//        Map<String, String> params = new HashMap<String, String>();
//        params.put("sort", "comm_part_sale_id");
//        params.put("filter.is_pay","0");
////        params.put("filter.isSy", "1");
//        params.put("order", "asc");
//        params.put("rows", limit + "");
//        params.put("page", page + "");
//        return params;
//    }

    /***
     * 获取未支付订单列表
     *
     * @param page
     * @return
     */
    public Map<String, String> getShopListParams(int page,String warehouse_id) {
        Map<String, String> params = new HashMap<String, String>();
        params.put("sort", "CREATE_DATE");
        params.put("is_pay","0");
        params.put("warehouse_id",warehouse_id);
        params.put("rows", limit + "");
        params.put("page", page + "");
        return params;
    }
    /***
     * 获取订单二维码
     *
     * @param businessId
     * @return
     */
    public Map<String, String> getErWeiMaParams(String businessId,String businessNo,String customId,
                                                String userId,String amount) {
        Map<String, String> params = new HashMap<String, String>();
        params.put("businessId", businessId);
        params.put("businessNo",businessNo);
        params.put("customId", customId);
        params.put("moneyTypeId", "20002401");
        params.put("userId", userId);
        params.put("amount", amount);
        return params;
    }
    /***
     * 获取查询订单支付状态
     *
     * @param businessNo
     * @return
     */
    public Map<String, String> getPayStateParams(String businessNo) {
        Map<String, String> params = new HashMap<String, String>();

        params.put("businessNo",businessNo);

        return params;
    }
    /***
     * 获取订单详情
     *
     * @param  keyId 订单ID
     * @return
     */
    public Map<String, String> getOrderParams(String keyId) {
        Map<String, String> params = new HashMap<String, String>();
        params.put("keyId", keyId);
        return params;
    }
    /***
     * 获取定金二维码
     *
     * @param  customId 客户id
     * @return
     */
    public Map<String, String> getEatnestParams(String customId,String userId,String amount) {
        Map<String, String> params = new HashMap<String, String>();
        params.put("customId", customId);
        params.put("moneyTypeId", "20000921");
        params.put("userId", userId);
        params.put("amount", amount);
        return params;
    }
    /***
     * 轮播图
     *
     * @param  imageType 轮播图
     * @return
     */
    public Map<String, String> getPicParams(String imageType) {
        Map<String, String> params = new HashMap<String, String>();
        params.put("imageType", imageType);
        return params;
    }
}
